<template>
	<view style="background-color:white">  
		<cu-custom style="height: 0px;"  class="navBox" bgColor="bg-gradual-blue" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">{{JobName}}</block>
		</cu-custom>
		<view class="container">
			<view class="top_bg">
				<view class="number_sy_box">
					<view v-if="false" class="number_sy_box_title">
						<text>已巡检/漏巡检·统计</text>
						<text v-if="false" style="position: absolute; right: 20rpx;z-index: 9999; font-size: 24rpx;color: #6c6c6c;">
							统计日期：1111
						</text>
					</view>
					<view class="number_sy_main">
						<view  @click="setCurrentSign(1)"  style="width: 50%; text-align: center; border-right: 1px solid #eee;position: relative;">
							<view v-if="currentSign==1" class="cu-tag1">
								<text class="cuIcon-check text-white"></text>
							</view>
							<view class="number_num_red">{{signCount.notSignCount}}</view>
							<view class="danwei">漏巡检</view>
						</view>
						<view @click="setCurrentSign(2)"  style="width: 50%; text-align: center; z-index: 9999; position: relative;">
							<view v-if="currentSign==2" class="cu-tag1">
								<text class="cuIcon-check text-white"></text>
							</view>
							<view class="number_num2">{{signCount.signedCount}}</view>
							<view class="danwei">已巡检</view>
						</view>
						<image mode="widthFix" class="xiaoding_bg" :src="Intersect"></image>
					</view>
				</view>
			</view>
			<view v-if="timeSlotList.length>0" class="goods-header-wrap">
				<view  v-for="(item,index) in timeSlotList" :key="index" class="goods-header-item goods-header-item-action" :class="{'goods-header-item-active' : index+1 == goodsNav}" @click="setNav(index+1)">
					{{item.BTime}}~{{item.ETime}}
				</view>
			</view>

			<!-- 漏巡检列表 -->
			<view v-if="currentSign==1" class="box">
				<view v-if="louList.length>0">
					<view class="eachitem" v-for="(item,index) in louList" :key="index">
						<view class="sort" v-if="index<9">0{{index+1}}</view>
						<view class="sort" v-if="index>=9">{{index+1}}</view>
						<view class="leftImg">
							<image v-if="item.qrcode_type==1" :src="dianwei"></image>
							<image v-if="item.qrcode_type==2" :src="dianwei2"></image>
						</view>
					
						<view :class="item.qrcode_type==1?'centerText':'centerText2'">
							<view class="itemName">
								<text>{{item.name}}</text>
								<text>{{chooseDate}}</text>
							</view>
							<view class="itemAddress">
								<text>{{item.city}}</text>
								<text>|</text>
								<view class="area">{{item.area}}</view> 
							</view>
						</view>
						
						<view class="rightImg">
							<image :src="lou"></image>
						</view>
					</view>
				</view>
				<view style="height: 1200rpx;" v-if="louList.length<=0">
					<image class="signok-image" :src="signok"></image>
					<view class="empty-text">
						<text>已完成所有点位巡检，</text>
						<text class="view-completed" @click="setCurrentSign(2)">查看已完成</text>
					</view>
				</view>
			</view>
			<!-- 已巡检列表 -->
			<view v-if="currentSign==2" class="box">
				<view class="eachitem" v-for="(item,index) in sngnedList" :key="index">
					<view class="sort" v-if="index<9">0{{index+1}}</view>
					<view class="sort" v-if="index>=9">{{index+1}}</view>
					<view class="leftImg">
						<image v-if="item.qrcode_type==1" :src="dianwei"></image>
						<image v-if="item.qrcode_type==2" :src="dianwei2"></image>
					</view>
			
					<view :class="item.qrcode_type==1?'centerText':'centerText2'">
						<view class="itemName">
							<text>{{item.name}}</text>
							<text>{{chooseDate}}</text>
						</view>
						<view class="itemAddress">
							<text>{{item.city}}</text>
							<text>|</text>
							<view class="area">{{item.area}}</view> 
						</view>
					</view>
					
					<!-- <view class="rightImg">
						<image :src="jian"></image>
					</view> -->
					<!-- 新增查看按钮 -->
					<view class="view-btn" @click="viewDetail(item)">
						<text>查看</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import request from "@/common/request.js";
	export default {
		components: {
		},
		data() {
			return {
				currentSign:1,
				JobName:'',
				signCount:{
					notSignCount:0,
					signedCount:0,
					allSignCount:0,
				},
				currentGroup:1,
				goodsNav: 1,
				louList: [],
				sngnedList: [],
				Intersect:this.$request22.baseUrl1+'/Resource/Sg/rank/Intersect.png',
				dianwei:this.$request22.baseUrl1+'/Resource/Sg/rank/dianwei.png',
				dianwei2:this.$request22.baseUrl1+'/Resource/Sg/rank/dianwei2.png',
				lou:this.$request22.baseUrl1+'/Resource/Sg/rank/lou.png',
				jian:this.$request22.baseUrl1+'/Resource/Sg/rank/jian.png',
				signok:this.$request22.baseUrl1+'/Resource/Sg/Scan/signok.png',
				getData:{
					jobId:'656128356105850880',
					timeSlotId:'',
				},
				timeSlotList:[]
			}
		},
		onLoad(option) {
			var that=this
			that.getData.jobId=option.jobId
			that.GetJobTimeSlot(option.jobId)
			that.JobName=option.JobName
		},
		onReady(){
		},
		methods: {
			// 其他方法保持不变
			viewDetail(item) {
				console.log('viewDetail:'+JSON.stringify(item))
				// 跳转到详情页面，并传递巡检项的ID或其他必要参数
				uni.navigateTo({
					url: `/pages-others/signdetail?qrcodeid=${item.qrcode_id}&signid=${item.SignId}&showReSign=1` // 假设 item.id 是巡检项的唯一标识 
				});
			},
			setCurrentSign(e){
				var that=this
				that.currentSign=e
			},
			changNav(e){
				var that=this
				that.currentGroup=e
			},
			setNav(goodsNav) {
				let that=this
				that.goodsNav=goodsNav
				that.getData.timeSlotId=that.timeSlotList[goodsNav-1].Id
				that.getTodayData()
			},
			GetJobTimeSlot(jobId){
				uni.showLoading({
					title: '加载中'
				})
				var that=this
				let opts={
					url:'api/GetJobTimeSlot',
					method:'get'
				}
				let getdata={
					jobId:jobId
				}
				request.httpTokenRequest(opts,getdata).then(res=>{
					uni.hideLoading();
					if(res.data.code==1){
						that.timeSlotList=res.data.data
						if(that.timeSlotList.length>0){
							that.getData.timeSlotId=that.timeSlotList[0].Id
							that.goodsNav=1
							that.getTodayData()
						}else{
							that.goodsNav=1
							that.getTodayData()
						}
					}else{
						uni.hideLoading();
						uni.showToast({
							title: '获取失败，请稍后再试',
							icon:'none',
							duration: 2000
				
						})
					}
				})
			},
			// 获取今日巡检概况数据
			getTodayData(){
				uni.showLoading({
					title: '加载中'
				})
				var that=this
				let opts={
					url:'api/GetSignTotalData',
					method:'get'
				}
				request.httpTokenRequest(opts,that.getData).then(res=>{
					uni.hideLoading();
					if(res.data.code==1){
						that.signCount.signedCount=res.data.data.signed
						that.signCount.notSignCount=res.data.data.nodSigned
						that.signCount.allSignCount=res.data.data.all
						let newArr=res.data.data.notSignQrodeList
						let signedQrodeList=res.data.data.signedQrodeList
						let obj={
							name:'',
							city: 'WBM',
							area:'',
							qrcode_type:''
						}
						that.louList=[]
						for(var i=0;i<newArr.length;i++){
							let item=newArr[i]
							obj={
								name:item.qrcode_title,
								city: 'WBM',
								area:item.qrcode_des,
								qrcode_type:1
							}
							that.louList.push(obj)
						}
						
						let obj1={
							name:'',
							city: 'WBM',
							area:'',
							qrcode_type:''
						}
						that.sngnedList=[]
						for(var i=0;i<signedQrodeList.length;i++){
							let item=signedQrodeList[i]
							obj1={
								name:item.qrcode_title,
								city: 'WBM',
								area:item.qrcode_des,
								qrcode_type:1,
								qrcode_id:item.Id,
								SignId:item.SignId
							}
							that.sngnedList.push(obj1)
						}
					}else{
						
						uni.hideLoading();
						uni.showToast({
							title: '获取失败，请稍后再试',
							icon:'none',
							duration: 2000

						})
					}
				})
			},
		},
		filters: {

		}
	}
</script>

<style lang="scss" scoped>
	.cu-tag1{
		border-radius: 200rpx;
		position: absolute;
		top: -20rpx;
		right: 100rpx;
		font-size: 20rpx;
		padding: 0rpx 10rpx;
		height: 28rpx;
		color: #ffffff;

		vertical-align: middle;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		box-sizing: border-box;
		font-family: Helvetica Neue, Helvetica, sans-serif;
		white-space: nowrap;
		background-color: #4bac7f;
		z-index: 999999;
	}
	.box{
		width:100%;
		margin-top: 0rpx;
	}
	.eachitem{
		border-bottom: 1px solid #e1e1e1;
		width:100%;
		height: 130rpx;
		display: flex;
		align-items: center;
		.sort{
			font-size: 16px;
			color: #888888;
			line-height: 130rpx;
			margin-left: 20rpx;
			margin-right: 5rpx;
		}
		.leftImg{
			margin-right: 10rpx;
			image{
				width:70rpx;
				height: 70rpx;
			}
			
		}
		.centerText{
			width: 70%;
			.itemName{
				:nth-child(1){
					font-weight: 700;
					font-size: 16px;
					color: black;
				}
				
				:nth-child(2){
					margin-left: 10rpx;
				}
				margin-bottom: 5rpx;
			}
			.itemAddress{
				display: flex;
				align-items: center;
				:nth-child(2){
					margin:0 6rpx;
				}
				.area{
					color: #37afe2;
					width: 70%;
					height: 40rpx;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis
				}
			}
		}
		.centerText2{
			width: 70%;
			color: #e96309;
			.itemName{
				:nth-child(1){
					font-weight: 700;
					font-size: 16px;
					
				}
				:nth-child(2){
					margin-left: 10rpx;
				}
				margin-bottom: 5rpx;
			}
			.itemAddress{
				display: flex;
				align-items: center;
				:nth-child(2){
					margin:0 6rpx;
				}
				.area{
					margin-left: 8rpx;
					width: 70%;
					height: 40rpx;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis
				}
			}
		}
		.rightImg{
			image{
				width:50rpx;
				height: 50rpx;
			}
			
		}
	}
	// .img1{
	// 	width:70rpx;
	// 	height: 70rpx;
	// }
	// .img2{
	// 	width:70rpx;
	// 	height: 70rpx;
	// 	margin-right: 10rpx;
	// }
	// 以上是我修改
	.container {
		position: relative;
	}
	
	.top_bg {
		width: 750rpx;
		height: 170rpx;
		position: relative;
		margin-top: 30rpx;
	}
	.top_bg1 {
		width: 750rpx;
		height: 40rpx;
		position: relative;
	}
	.one_box {
		width: 750rpx;
		height: 350rpx;
		line-height: 350rpx;
		position: absolute;
		left: 0;
		bottom: 110rpx;
		display: flex;
		justify-content: space-around;
		coloe:white;
	}
	.number_num_red{
		font-size: 70rpx;
		font-weight: 500;
		color: red;
	}
	.number_num111 {
		font-size: 50rpx;
		font-weight: 500;
		color: white;
	}

	.top_name {
		width: 100%;
		height: 55rpx;
		line-height: 60rpx;
		color: #f2f2f2;
		font-size: 26rpx;
		text-align: center;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.top_sy {
		width: 100%;
		height: 40rpx;
		line-height: 40rpx;
		font-size: 24rpx;
		color: rgba(255, 255, 255, .7);
		text-align: center;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.top_sy span {
		font-size: 20rpx !important;
	}

	.num_one {
		position: relative;
	}

	.huangguan1 {
		width: 60px;
		height: 60px;
		position: absolute;
		right: -10rpx;
		top: -18*2rpx;
	}

	.num_one .top3_head {
		width: 150rpx;
		height: 150rpx;
		border-radius: 100%;
		margin: 15rpx 0 0 30rpx;
		border: 4rpx solid #ffdd3c;
	}

	.num_two {
		position: relative;
	}

	.huangguan2 {
		width: 100rpx;
		height: 100rpx;
		position: absolute;
		right: 15rpx;
	}

	.num_two .top3_head {
		width: 120rpx;
		height: 120rpx;
		border-radius: 100%;
		margin: 45rpx 0 0 45rpx;
		border: 4rpx solid #bcdcdf;
	}

	.num_three {
		position: relative;
	}

	.huangguan2 {
		width: 100rpx;
		height: 100rpx;
		position: absolute;
		right: 15rpx;
	}

	.num_three .top3_head {
		width: 120rpx;
		height: 120rpx;
		border-radius: 100%;
		margin: 45rpx 0 0 45rpx;
		border: 4rpx solid #e29d85;
	}

	// 第二块
	.number_sy_box {
		width: 700rpx;
		height: 170rpx;
		background-color: #FFFFFF;
		position: absolute;
		left: 25rpx;
		border-radius: 20rpx;
		//bottom: 0rpx;
		z-index: 999;
		padding: 22rpx;
		box-shadow: 3px 3px 15px 3px rgba(0, 0, 0, 0.1)
	}

	.number_sy_box_title {
		color: #888888;
		// font-weight: 500;
		font-size: 28rpx;
		display: flex;
		z-index: 9999;
		justify-content: space-between;
	}

	.number_sy_main {
		width: 100%;
		height: 124rpx;
		padding-top: 20rpx;
		line-height: 52rpx;
		// background: red;
		display: flex;
		justify-content: space-around;
		position: relative;
	}

	.xiaoding_bg {
		position: absolute;
		right: -22rpx;
		bottom: -30rpx;
		width: 140rpx;
	}

	.number_num1 {
		font-size: 70rpx;
		font-weight: 500;
		color: #2fc04f;
	}

	.number_num2 {
		font-size: 70rpx;
		font-weight: 500;
		color: #4bac7f;
	}
	.number_num3 {
		font-size: 70rpx;
		font-weight: 500;
		color: #1F479E;
	}

	.danwei {
		height: 60rpx;
		line-height: 60rpx;
		font-size: 32rpx;
		color: #c9c9c9;
	}

	// 列表
	.rankList_box {
		width: 750rpx;
		min-height: 200rpx;
		margin-top: 130rpx;
	}

	.rankItem:last-child {
		border: none;
	}

	.rankItem {
		width: 700rpx;
		height: 140rpx;
		margin: 0px auto;
		border-bottom: 1px solid #e9e9e9;
	}

	.rankIndex {
		width: 60rpx;
		height: 140rpx;
		line-height: 140rpx;
		text-align: center;
		color: #CCCCCC;
		font-size: 40rpx;
		float: left;
	}

	.HeardBox {
		width: 80rpx;
		height: 80rpx;
		margin: 10rpx;
		// border-radius: 100%;
		overflow: hidden;
		float: left;
		margin-right: 25rpx;
		margin-left: 10rpx !important;
	}


	.NameBox {
		width: 400rpx;
		height: 140rpx;
		float: left;
		padding-top: 10rpx;
		box-sizing: border-box;
	}

	.NameBox view {
		height: 50rpx;
		line-height: 70rpx;
	}

	.userName {
		min-width: 90rpx;
		font-size: 30rpx;
		float: left;
		margin-right: 20rpx;
	}

	.download_box {
		width: 80rpx;
		height: 140rpx;
		// background-color: red;
		float: right;

	}

	.download_box image {
		width: 45rpx;
		margin: 50rpx auto;
		display: block;
	}
	
	.goods-header-wrap {
		display: flex;
		align-items: center;
		padding: 24rpx;
		background: #FFFFFF;
		margin: auto;
		margin-bottom: 10rpx;
		padding-top: 50rpx;
	}
	.goods-header-item{
		width:50%;
		text-align: center;
	}
	.goods-header-item-active{
		font-size: 30rpx;
		font-color: #333333;
		font-weight: bold;
		position: relative;
	}
	.goods-header-item-active::after{
		position: absolute;
		left: 50%;
		right: 0;
		background: #4372fe;
		height: 8rpx;
		content: "";
		bottom: -12rpx;
		width: 60rpx;
		margin-left: -30rpx;
		border-radius: 200rpx;
	}
	.goods-header-item-action {
		// font-size: 32rpx;
		// font-color: #333333;
		// font-weight: bold;
		position: relative;
		margin:auto;
	}
	
	.goods-header-item-action::after {
		// position: absolute;
		// left: 0;
		// right: 0;
		// background: #4372fe;
		// height: 8rpx;
		// content: "";
		// bottom: -12rpx;
	}
	.eachitem {
		position: relative; // 确保按钮可以定位
		// 其他样式保持不变
	}
	
	.view-btn {
		position: absolute;
		right: 20rpx;
		top: 50%;
		transform: translateY(-50%);
		background-color: #007AFF;
		color: white;
		padding: 10rpx 20rpx;
		border-radius: 10rpx;
		font-size: 28rpx;
		cursor: pointer;
	}
	
	//已完成巡检，展示图片
	.empty-container {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		height: 100%;
		margin-top: 100rpx; // 根据需要调整
	}

	.signok-image {
		width: 240rpx;
		height: 240rpx;
		margin-bottom: 20rpx;
		margin-left: 50%;
		left: -120rpx;
		margin-top: 100rpx;
	}

	.empty-text {
		margin-top: 50rpx;
		font-size: 28rpx;
		color: #888888;
		text-align: center;
	}

	.view-completed {
		color: #007AFF;
		cursor: pointer;
	}
</style>
